package camel.corp.universalcopy.screenshot;

import android.animation.ValueAnimator;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.drawable.GradientDrawable;
import android.hardware.display.VirtualDisplay;
import android.media.Image;
import android.media.ImageReader;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Display;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.Toast;
import androidx.appcompat.app.m;
import b.b.a.a.i.h;
import com.camel.corp.universalcopy.E;
import com.camel.corp.universalcopy.screenshot.ScreenshotActivity;
import com.camel.corp.universalcopy.screenshot.a;
import com.camel.corp.universalcopy.screenshot.b;
import com.camel.corp.universalcopy.screenshot.c;
import com.camel.corp.universalcopy.screenshot.d;
import com.camel.corp.universalcopy.screenshot.e;
import com.crashlytics.android.Crashlytics;
import com.google.firebase.d.b.a;
import com.google.firebase.d.b.c.a;
import com.google.firebase.d.b.h.b;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

public class ScreenshotActivity extends m {
  private static MediaProjection r;
  
  private int A;
  
  private int B;
  
  private int C;
  
  private c D;
  
  private String E = null;
  
  private Image F = null;
  
  private MediaProjectionManager s;
  
  private ImageReader t;
  
  private Handler u;
  
  private Display v;
  
  private VirtualDisplay w;
  
  private int x = 0;
  
  private final int y = 7;
  
  private int z;
  
  private void a(Bitmap paramBitmap) {
    a a = a.a(paramBitmap);
    h h = a.a().b().a(a);
    h.a(new e(this, paramBitmap));
    h.a(new d(this, paramBitmap));
  }
  
  private void a(b paramb) {
    List list = paramb.a();
    ArrayList arrayList = new ArrayList(list.size());
    for (b.d d : list)
      arrayList.add(new E(d.a(), d.d(), "importantView")); 
    if (arrayList.size() > 0) {
      Intent intent = new Intent(getApplicationContext(), com.camel.corp.universalcopy.CopyActivity.class);
      intent.setFlags(268435456);
      intent.putExtra("ocr_mode", true);
      if (!"com.camel.corp.universalcopy".equals(this.E))
        intent.addFlags(32768); 
      intent.putParcelableArrayListExtra("copy_nodes", arrayList);
      intent.putExtra("source_package", this.E);
      startActivity(intent);
    } else {
      Toast.makeText(this, 2131755091, 1).show();
    } 
    finish();
  }
  
  private void q() {
    Point point = new Point();
    this.v.getRealSize(point);
    this.A = point.x;
    this.B = point.y;
    this.t = ImageReader.newInstance(this.A, this.B, 1, 2);
    this.w = r.createVirtualDisplay("screencap", this.A, this.B, this.z, 9, this.t.getSurface(), null, this.u);
    this.t.setOnImageAvailableListener(new a(this, null), this.u);
  }
  
  private void r() { startActivityForResult(this.s.createScreenCaptureIntent(), 100); }
  
  private void s() { this.u.post(new c(this)); }
  
  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent) {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("Result code = ");
    stringBuilder.append(paramInt2);
    Log.d("universal_copy", stringBuilder.toString());
    if (paramInt1 == 100) {
      r = this.s.getMediaProjection(paramInt2, paramIntent);
      if (r != null) {
        this.z = (getResources().getDisplayMetrics()).densityDpi;
        this.v = getWindowManager().getDefaultDisplay();
        q();
        this.D = new c(this, this);
        if (this.D.canDetectOrientation())
          this.D.enable(); 
        r.registerCallback(new b(this, null), this.u);
        return;
      } 
      Toast.makeText(this, 2131755189, 1).show();
      finish();
    } 
  }
  
  protected void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    setContentView(2131492949);
    this.E = getIntent().getStringExtra("source_package");
    try {
      this.s = (MediaProjectionManager)getSystemService("media_projection");
      (new a(this)).start();
      getWindow().getDecorView().setSystemUiVisibility(1280);
      GradientDrawable gradientDrawable = (GradientDrawable)findViewById(2131296479).getBackground();
      ValueAnimator valueAnimator = ValueAnimator.ofInt(new int[] { 1, 12 });
      valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
      valueAnimator.setDuration(500L);
      valueAnimator.setRepeatCount(-1);
      valueAnimator.setRepeatMode(2);
      valueAnimator.addUpdateListener(new b(this, gradientDrawable));
      valueAnimator.start();
      r();
      return;
    } catch (NoClassDefFoundError paramBundle) {
      Crashlytics.a(paramBundle);
      Toast.makeText(this, 2131755201, 1).show();
      finish();
      return;
    } 
  }
  
  public void p() {
    try {
      if (this.F != null) {
        Image.Plane[] arrayOfPlane = this.F.getPlanes();
        ByteBuffer byteBuffer = arrayOfPlane[0].getBuffer();
        int i = arrayOfPlane[0].getPixelStride();
        int j = arrayOfPlane[0].getRowStride();
        int k = this.A;
        Bitmap bitmap = Bitmap.createBitmap(this.A + (j - k * i) / i, this.B, Bitmap.Config.ARGB_8888);
        bitmap.copyPixelsFromBuffer(byteBuffer);
        a(bitmap);
      } 
      Image image = this.F;
      if (image != null) {
        image.close();
        return;
      } 
    } catch (Exception exception) {
      exception.printStackTrace();
      Image image = this.F;
      if (image != null) {
        image.close();
        return;
      } 
    } finally {
      ImageReader imageReader;
    } 
  }
}


/* Location:              D:\Users\alienware\AndroidStudioProjects\Lazero\sample\sampler\classes-dex2jar\com\camel.jar!\camel\cor\\universalcopy\screenshot\ScreenshotActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.0.7
 */